Install/Configure httpd
2010/05/30 |
This is an example to build Web Server. Install httpd for it.
In addition to do it, Install PHP because there are often used with Web Server.
And it's also neccessary to configure router so that TCP and UDP packets to 80 and 443 can pass through. |
|
[1] | Install httpd and PHP |
[root@www ~]# yum -y install httpd php php-mbstring php-pear # remove sample page [root@www ~]# rm -f /etc/httpd/conf.d/welcome.conf # remove sample page [root@www ~]# rm -f /var/www/error/noindex.html # create a link [root@www ~]# ln -s /usr/bin/perl /usr/local/bin/perl |
[2] | Here is an example to configure Apache. This example shows that users can open to the public their Web site and can execute CGI in any directories. ( SSI is disabled because it's not used so often ) |
[root@www ~]# vi /etc/httpd/conf/httpd.conf # line 44: change ServerTokens Prod # line 74: change to ON KeepAlive On # line 248: webmaster's address ServerAdmin webmaster@srv.world # line 262: server's name ServerName www.srv.world:80 # line 317: change (disable Indexes) Options FollowSymLinks ExecCGI # line 324: change AllowOverride All # line 352: make it comment # UserDir disable# line 359: uncomment UserDir public_html # line 367 - 378 : uncomment all <Directory /home/*/public_html> AllowOverride All # change Options ExecCGI # enable CGI <Limit GET POST OPTIONS> Order allow,deny Allow from all </Limit> <LimitExcept GET POST OPTIONS> Order deny,allow Deny from all </LimitExcept> </Directory> # line 388: add file name that it can access only with directory's name DirectoryIndex index.html index.cgi index.php # line 521: change ServerSignature Off # line 744: make it comment # AddDefaultCharset UTF-8# line 781: make valid and add file-type that apache looks them CGI AddHandler cgi-script .cgi .pl [root@www ~]# /etc/rc.d/init.d/httpd start Starting httpd: [ OK ] [root@www ~]# chkconfig httpd on |
[3] | Create a HTML test page and Make sure httpd is working. |
[root@www ~]# vi /var/www/html/index.html <html>
<body> <div style="width:100%;font-size:40px;font-weight:bold;text-align:center"> Test Page </div> </body> </html> |
[4] | Create a CGI test page and Make sure the setting is no ploblem. |
[root@www ~]# vi /var/www/html/index.cgi #!/usr/local/bin/perl print "Content-type: text/html\n\n"; print <<"EOM"; <html> <body> <div style="width:100%;font-size:40px;font-weight:bold;text-align:center"> CGI Test Page </div> </body> </html> EOM exit; [root@www ~]# chmod 705 /var/www/html/index.cgi |
[5] | Create a PHP test page and Make sure the setting is no ploblem. |
[root@www ~]# vi /var/www/html/index.php <html>
<body> <div style="width:100%;font-size:40px;font-weight:bold;text-align:center"> <?php print Date("Y/m/d"); ?> </div> </body> </html> |